<?php
require_once('../carbox.php');
if(!carbox_check_session( ) || $_SESSION['profile'] != 5)
	header('Location: http://'.$_SERVER['HTTP_HOST'].'/carbox/login.php');
$sql = "
	SELECT u.id, u.login, p.label AS profile, ccu.cerberus_user_id, DATE_FORMAT(u.created_on, '%d/%m/%Y') AS fdate
	FROM User u
	INNER JOIN Profile AS p ON u.profile_id = p.id
	LEFT OUTER JOIN CerberusUser AS ccu ON u.id = ccu.carbox_user_id
	WHERE p.id NOT IN (6)
	ORDER BY u.login
";
$query = end(carbox_query($sql));
?>
<div class="container-fluid">
	<div class="row-fluid">
		<div class="span12">		
			<table class="table table-condensed" id="table-users">
				<thead>
					<tr>
						<th><input type="checkbox" class="checkbox" id="checkbox-select-all-users" /></th>						
						<th>Usuário</th>
						<th>Perfil</th>
						<th>Cerberus ID</th>
						<th>Criado em</th>
					</tr>
				</thead>
				<tbody>
					<?
					for($i = 0; $i < count($query); ++$i) {
						echo '
							<tr>
								<td><input type="checkbox" class="checkbox checkbox-processes" value="'.$query[$i]['id'].'" /></td>
								<td>'.$query[$i]['login'].'</td>
								<td>'.$query[$i]['profile'].'</td>								
								<td>'.$query[$i]['cerberus_user_id'].'</td>
								<td>'.$query[$i]['fdate'].'</td>
							</tr>
						';
					}
					?>
				</tbody>
			</table>
		</div>		
	</div>
</div>
<div class="modal hide fade" id="modal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
	<div class="modal-header">
		<button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
		<h3 id="myModalLabel"></h3>
	</div>
	<div class="modal-body">
	</div>
	<div class="modal-footer">
		<button type="button" class="btn" id="btn-confirm">Confirmar</button>
	</div>
</div>
<script type="text/javascript"> $(carbox_ui_users( )); </script>
